#pragma once
#include <vector>
#include <glm/glm.hpp>
#include "shader.h"
#include "model.h"
class Config {
public:
	//���򴰿���Ϣ
	unsigned windowWidth = 1200;	
	unsigned windowHeight = 800;
    const char* windowTitle = "人群疏散仿真平台";
	//��ɫ��
	std::vector<Shader*> shaders;//Shader�� ��shader program
	Shader* lineShader;
	//ģ��
	std::vector<Model*> models;
	bool keyboard[512];

	//camera
	float cameraMoveSpeed = 10.f;				//�������ƶ��ٶȣ����̣�
	float cameraOpticMoveSpeed = 0.01f;			//�������ӽ��ƶ��ٶȣ����꣩
		//������״̬��Ϣ
	glm::vec3 cameraPos = glm::vec3(0.f, 1.f, 30.f);
	glm::vec3 cameraDir = glm::vec3(0.f, 0.f, -1.f);
	glm::vec3 cameraUp = glm::vec3(0.f, 1.f, 0.f);
	float fovY = 45.f;
	float zNear = 0.01f;
	float zFar = 1000.f;
	float pitch = 0;
	float yaw = 0;

	//ģ�������ٶȣ��������֣�
	float scaleSpeed = 0.1f;

	//ƽ�й�Դ
	glm::vec3 lightDir = glm::normalize(glm::vec3{ 1,-1,1 });
	glm::vec3 lightPos = glm::vec3{ 0,0,0 };
	//����ʵ��********************************
	glm::vec3 space_ship_translate = { 0,10,0 };

	//��������
	int N_indiv;
	float space_ship_rotate = 0;
	//���ݼ���״̬����������״̬
	void updataCamera(float frameDeltaTime) {
		if (keyboard[GLFW_KEY_W]) {
			cameraPos += cameraDir * cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}
		if (keyboard[GLFW_KEY_S]) {
			cameraPos -= cameraDir * cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}
		if (keyboard[GLFW_KEY_A]) {
			cameraPos += glm::cross(cameraUp, cameraDir) * cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}
		if (keyboard[GLFW_KEY_D]) {
			cameraPos -= glm::cross(cameraUp, cameraDir) * cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}
		if (keyboard[GLFW_KEY_SPACE]) {
			cameraPos += cameraUp * cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}
		if (keyboard[GLFW_KEY_LEFT_CONTROL]) {
			cameraPos -= cameraUp * cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}

		//����ʵ��

		if (keyboard[GLFW_KEY_UP]) {
			space_ship_translate += glm::vec3(0,1,0) * cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}
		if (keyboard[GLFW_KEY_DOWN]) {
			space_ship_translate -= glm::vec3(0, 1, 0) * cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}
		if (keyboard[GLFW_KEY_LEFT]) {
			space_ship_translate -= glm::vec3(1, 0, 0) * cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}
		if (keyboard[GLFW_KEY_RIGHT]) {
			space_ship_translate += glm::vec3(1, 0, 0) * cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}
		if (keyboard[GLFW_KEY_O]) {
			space_ship_translate -= glm::vec3(0, 0, 1) * cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}
		if (keyboard[GLFW_KEY_L]) {
			space_ship_translate += glm::vec3(0, 0, 1) * cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}
		if (keyboard[GLFW_KEY_J]) {
			space_ship_rotate -= cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}
		if (keyboard[GLFW_KEY_K]) {
			space_ship_rotate +=cameraMoveSpeed * frameDeltaTime * (keyboard[GLFW_KEY_LEFT_SHIFT] ? 10.f : 1.f);
		}

		

		updataCameraDirect();
	}

	void updataCameraDirect() {
		cameraDir.x = cos(glm::radians(pitch)) * sin(glm::radians(yaw));
		cameraDir.y = sin(glm::radians(pitch));
		cameraDir.z = -cos(glm::radians(pitch)) * cos(glm::radians(yaw));
		cameraDir = glm::normalize(cameraDir);
	}
};
